const Emitter = require('events');

class MyEvent extends Emitter{
    constructor() {
        super();
        this.name = "MyEvent";
    }
}

let myEvent = new MyEvent();
myEvent.on('say', function(a, b) {
    console.log('触发事件', a, b, this); //this为myEvent, arrow 时为global
});

myEvent.emit('say', 10, 20);